#!/usr/bin/env python2

import requests
from random import random
import time
import json

user = r'http://campus.finance365.com/Rematch/UserCenter/21'
index = r'http://campus.finance365.com/Rematch/Index'

def tp(user_id):
    for i in range(2):
        url = r'http://campus.finance365.com/Rematch/Handler'
        #jsondata = json.dumps(
        #    {'user_id':user_id, 
        #     'rid':'8'+str(int(random()*100000000))+'c'
        #    })
        jsondata = {'user_id':user_id, 
             'rid':'8'+str(int(random()*100000000))+'c'
            }
        req = requests.Session()
        req.get(index)
        data = req.post(url, params=jsondata)
        print data.url
        print dir(data)
        #time.sleep(1)

if __name__ == "__main__":
    import sys

    if len(sys.argv) == 1 :
        dic = {'Usage :':sys.argv[0]+' id[, id, id]...'}
        for key, value in dic.items():
            print key, '\n\t', value
        exit()

    argv = [ x for x in sys.argv if x != sys.argv[0] ]

    map(tp, argv)
